﻿using DosTexPrj.Core.Models;
using FluentNHibernate.Mapping;

namespace DosTexPrj.Implement.NHibernate.Mapping
{
    public class RoleMapping : ClassMap<Role>
    {
        public RoleMapping()
        {
            Table("Roles");
            Id(x => x.Id, "RoleID").UnsavedValue(0).GeneratedBy.Identity();
            Map(x => x.RoleName, "RoleName").Not.Nullable().Length(100);
            HasMany<User>(x => x.UsersOfRole).KeyColumn("RoleID").AsBag()
                                            .Cascade.AllDeleteOrphan().Not.LazyLoad();
        }
    }
}